#!/bin/sh

if [ ! -n "$1" ] ;then
    echo "please input a service name!"
    exit
else
    echo "service name is pb$1"
fi

if [ ! -n "$2" ] ;then
    echo "please input a service port!"
    exit
else
    echo "service port is pb$2"
fi

git clone git@gitee.com:gtsoa/bsdemo.git

NAME=$1
PORT=$2

# 首字母大写
TNAME=${NAME^}

cd ./bsdemo

grep demo -rl ./ | xargs sed -i "s/demo/$NAME/g"
grep Demo -rl ./ | xargs sed -i "s/Demo/$TNAME/g"

grep 20000 -rl ./ | xargs sed -i "s/20000/$PORT/g"

mv bsdemopb bs${NAME}pb
mv bsdemosoa bs${NAME}soa
mv bs${NAME}pb/bsdemo.proto bs${NAME}pb/bs${NAME}.proto 

rm -rf .git

cd ../
mv bsdemo bs${NAME}
